import java.util.Arrays;
import java.util.Random;

/**
 * @Auther: MFM
 * @Date: 2021/7/15 - 07 - 15 - 15:33
 * @version: 1.0
 */

public class Work {
    static class Count {
        public int value = 0;
        public int times = 1;

        public Count(int value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return "{value=" + value +"次数:"+times +
                    '}';
        }
    }

    public static void main(String[] args) {
        Count[] nums = new Count[7];
        Random random = new Random();
        int index = 0;
        while (index < 7) {
            int num = random.nextInt(10) + 1;
            boolean exist = false;
            for (int i = 0; i < nums.length; i++) {
                if (nums[i] != null) {
                    if (nums[i].value==num){
                        exist = true;
                        nums[i].times++;
                        break;
                    }
                }else {
                    break;
                }
            }
            if (!exist) {
                nums[index]= new Count(num);
                index++;
            }

            for (int i = 0; i <nums.length ; i++) {
                for (int j = 0; j <nums.length ; j++) {

                }
            }
        }
        System.out.println(Arrays.toString(nums));
    }
}
